<?php
include('top.php');
require_once('pasmy/dbwaarden.php');
if(empty($_SESSION['taal'])) {
	session_destroy();
		Header( "HTTP/1.1 301 Moved Permanently" );
		 
		Header( "Location: login.php" ); 
}
/*echo "dbhost = $dbhost<br>";*/
echo "<br><br>";
$mysql_id = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($db, $mysql_id);

/*foreach($_POST as $sleutel => $waarde) {
		echo "sleutel = $sleutel en waarde = |$waarde| <br>";
		}*/
if(isset($_POST["prix"])) {
	if($_POST["pals"]=="-----"){?><META http-equiv="Refresh" content="0"; URL=delsaux.php><?php exit;}
	if($_POST["kilom"]=="-----"){?><META http-equiv="Refresh" content="0"; URL=delsaux.php><?php exit;}
	
$kilometers =$_POST["kilom"];
$paletten= $_POST["pals"];
?>

<table width="50%" border="1" align="center">
<tr><td><div style="text-align: center"><h3>Prix &agrave; facturer</h3></div></td></tr>

<?php

$sql="SELECT * FROM `delsaux` WHERE `km` = '$_POST[kilom]' AND `pal` = '$_POST[pals]'";

#$sql="SELECT * FROM `delsaux` WHERE `km` = '1-50'AND `pal` = '3'";

#echo "sql = $sql<br>";

$res = mysql_query($sql, $mysql_id);
while ($row = mysql_fetch_row($res)) {
	echo "<tr><td><div style=\"text-align: center\"><h3>$row[2]</h3></div></td></tr>";
	#echo "row = $row[0]<br>";
	}

echo "</table>";	
}
else {




$kilometers=array("-----","1-50","51-110","111-230","Eupen","Verviers","Luxembourg","Sankt-Vith");
$paletten=array("-----","1","2","3","4-8","9-18","+45 kubiek");
?>
<form action="delsaux.php" method="POST">
<table width="50%" align="center" border="1">
<tr>
<td colspan="2"><div style="text-align: center"><h3><font color="black">Prix Delsaux</font></h3></div></td>
</tr>
<tr>
<td width="25%"><div style="text-align: center"><h4><font color="black">Distance</font></h4></div></td>
<td width="25%"><div style="text-align: center"><h4><font color="black">Nombre de palettes</font></h4></div></td>
</tr>
<tr>
<td>
<div style="text-align: center"><select name="kilom">
<?php
while(list($key, $val)=each($kilometers)) {
	if (isset($kilom) && ($kilom == $val)) {
		echo '<option value="'.$val.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$val.'">'.$val.'</option>';
	}
}
?>
</select></div>
</td>
<td>
<div style="text-align: center"><select name="pals">
<?php
while(list($key, $val)=each($paletten)) {
	if (isset($pals) && ($pals == $val)) {
		echo '<option value="'.$val.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$val.'">'.$val.'</option>';
	}
}
?></select></div>
</td>
</tr>
<tr><td colspan="2"><div style="text-align: center">
<input type="submit" name="prix" value="Prix &agrave; facturer" />
</form>
</table>

<div style="text-align: center"><h3><a href="delsaux2.php">Voir tous les prix</a></h3></div>















<?php
}
include('footer.php');
?>